﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data.SqlClient;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.User.Identity.IsAuthenticated)
            Response.Redirect("login.aspx");


        int count_contact=0;
        int count_class = 0;
        string strsql = "SELECT count(*) as counter FROM member WHERE class!=''";
        SqlDataReader sdr = SQLHelper.SQLHelper.ExecReader(strsql);
        if (sdr.Read())
        {
            count_contact = (int)sdr[0];
        }

        strsql = "SELECT count(*) as counter FROM class";
        sdr = SQLHelper.SQLHelper.ExecReader(strsql);
        if (sdr.Read())
        {
            count_class = (int)sdr[0];
        }
        string role = "普通用户";

        if (Roles.IsUserInRole("超级管理员")) role="超极管理员";
        if (Roles.IsUserInRole("班级管理员")) role = "班级管理员";
        Label2.Text = string.Format("你的身份是{0}", role);
        Label1.Text = string.Format("本网站目前有 {0} 个班级, {1} 条联系人信息", count_class,count_contact);
        ;
    }
}